package net.wofly.common.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import net.wofly.right.domain.User;

/**
 * Created by LiuJianbo on 2017/10/16 0025.
 */
public class LoginInterceptor implements HandlerInterceptor {
    
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
        boolean flag = true;
        User customer = (User) request.getSession().getAttribute("customer");
        if (customer == null) {
            //response.sendRedirect("");
            //response.getWriter().write("{\"code\":-999,\"sms\":\"User is not login !\"}");
            //flag = false;
        }
        return flag;
    }
    
    @Override
    public void postHandle(
            HttpServletRequest request, HttpServletResponse response, Object o,
            ModelAndView modelAndView) throws Exception {
        
    }
    
    @Override
    public void afterCompletion(
            HttpServletRequest request, HttpServletResponse response, Object o, Exception e) throws Exception {
        
    }
}
